package com.D5Power.Editor
{
	import com.D5Power.Controler.CharacterControler;
	import com.D5Power.D5Game;
	import com.D5Power.Objects.CharacterObject;
	import com.D5Power.Objects.Direction;
	import com.D5Power.Objects.GameObject;
	import com.D5Power.Render.RenderCharacter;
	import com.D5Power.Stuff.HSpbar;
	import com.D5Power.graphicsManager.GraphicsResource;
	
	import flash.display.Stage;
	import flash.events.Event;
	
	public class Demo extends D5Game
	{
		public function Demo(config:String, stg:Stage)
		{
			super(config, stg);
			configDirection();
		}
		
		override protected function init(e:Event=null):void
		{
			super.init(e);
			npc();
		}
		
		protected function npc():void
		{
			var ctr:CharacterControler = new CharacterControler(_scene.perc,CharacterControler.KEY);
			var player:CharacterObject = new CharacterObject(ctr);
			
			var g:GraphicsResource = new GraphicsResource(null,'qun',8,9,15);
			g.addLoadResource(["asset/DemoCharacter.png"]);
			
			player.graphicsRes = g;
			player.render = new RenderCharacter();
			player.speed=1.2;
			player.setName('测试角色',0xffffff,0x000000);
			player.hpMax = 100;
			player.hp = 80;
			player.hpBar = new HSpbar(player,'hp','hpMax');
			
			player.setPos(100,100);
			_camera.focus(player);
			
			_scene.createPlayer(player);
		}
		
		private function configDirection():void
		{
			GameObject.DEFAULT_DIRECTION.Stop=0;
			GameObject.DEFAULT_DIRECTION.Down = 1;
			GameObject.DEFAULT_DIRECTION.LeftDown = 5;
			GameObject.DEFAULT_DIRECTION.Left = 2;
			GameObject.DEFAULT_DIRECTION.LeftUp = 7;
			GameObject.DEFAULT_DIRECTION.Up = 4;
			GameObject.DEFAULT_DIRECTION.RightUp = 8;
			GameObject.DEFAULT_DIRECTION.Right = 3;
			GameObject.DEFAULT_DIRECTION.RightDown = 6;
		}
	}
}